package com.tencent.mm.opensdk.modelpay;

import android.os.Bundle;
import android.util.Log;
import com.tencent.mm.opensdk.b.a;
import com.tencent.mm.opensdk.modelbase.BaseReq;

public class PayReq extends BaseReq {
    public class Options {
        public static final int INVALID_FLAGS = -1;
        public String callbackClassName;
        public int callbackFlags;

        public Options() {

            this.callbackFlags = -1;
        }

        public void fromBundle(Bundle arg2) {
            this.callbackClassName = a.b(arg2, "_wxapi_payoptions_callback_classname");
            this.callbackFlags = a.a(arg2, "_wxapi_payoptions_callback_flags");
        }

        public void toBundle(Bundle arg3) {
            arg3.putString("_wxapi_payoptions_callback_classname", this.callbackClassName);
            arg3.putInt("_wxapi_payoptions_callback_flags", this.callbackFlags);
        }
    }

    private static final int EXTDATA_MAX_LENGTH = 1024;
    private static final String TAG = "MicroMsg.PaySdk.PayReq";
    public String appId;
    public String extData;
    public String nonceStr;
    public Options options;
    public String packageValue;
    public String partnerId;
    public String prepayId;
    public String sign;
    public String signType;
    public String timeStamp;

    public PayReq() {

    }

    public boolean checkArgs() {
        boolean v0 = false;
        if(this.appId == null || this.appId.length() == 0) {
            Log.e("MicroMsg.PaySdk.PayReq", "checkArgs fail, invalid appId");
        }
        else {
            if(this.partnerId != null && this.partnerId.length() != 0) {
                if(this.prepayId != null && this.prepayId.length() != 0) {
                    if(this.nonceStr != null && this.nonceStr.length() != 0) {
                        if(this.timeStamp != null && this.timeStamp.length() != 0) {
                            if(this.packageValue != null && this.packageValue.length() != 0) {
                                if(this.sign != null && this.sign.length() != 0) {
                                    if(this.extData != null && this.extData.length() > 1024) {
                                        Log.e("MicroMsg.PaySdk.PayReq", "checkArgs fail, extData length too long");
                                        return v0;
                                    }

                                    return true;
                                }

                                Log.e("MicroMsg.PaySdk.PayReq", "checkArgs fail, invalid sign");
                                return v0;
                            }

                            Log.e("MicroMsg.PaySdk.PayReq", "checkArgs fail, invalid packageValue");
                            return v0;
                        }

                        Log.e("MicroMsg.PaySdk.PayReq", "checkArgs fail, invalid timeStamp");
                        return v0;
                    }

                    Log.e("MicroMsg.PaySdk.PayReq", "checkArgs fail, invalid nonceStr");
                    return v0;
                }

                Log.e("MicroMsg.PaySdk.PayReq", "checkArgs fail, invalid prepayId");
                return v0;
            }

            Log.e("MicroMsg.PaySdk.PayReq", "checkArgs fail, invalid partnerId");
        }

        return v0;
    }

    public void fromBundle(Bundle arg2) {
        super.fromBundle(arg2);
        this.appId = a.b(arg2, "_wxapi_payreq_appid");
        this.partnerId = a.b(arg2, "_wxapi_payreq_partnerid");
        this.prepayId = a.b(arg2, "_wxapi_payreq_prepayid");
        this.nonceStr = a.b(arg2, "_wxapi_payreq_noncestr");
        this.timeStamp = a.b(arg2, "_wxapi_payreq_timestamp");
        this.packageValue = a.b(arg2, "_wxapi_payreq_packagevalue");
        this.sign = a.b(arg2, "_wxapi_payreq_sign");
        this.extData = a.b(arg2, "_wxapi_payreq_extdata");
        this.signType = a.b(arg2, "_wxapi_payreq_sign_type");
        this.options = new Options();
        this.options.fromBundle(arg2);
    }

    public int getType() {
        return 5;
    }

    public void toBundle(Bundle arg3) {
        super.toBundle(arg3);
        arg3.putString("_wxapi_payreq_appid", this.appId);
        arg3.putString("_wxapi_payreq_partnerid", this.partnerId);
        arg3.putString("_wxapi_payreq_prepayid", this.prepayId);
        arg3.putString("_wxapi_payreq_noncestr", this.nonceStr);
        arg3.putString("_wxapi_payreq_timestamp", this.timeStamp);
        arg3.putString("_wxapi_payreq_packagevalue", this.packageValue);
        arg3.putString("_wxapi_payreq_sign", this.sign);
        arg3.putString("_wxapi_payreq_extdata", this.extData);
        arg3.putString("_wxapi_payreq_sign_type", this.signType);
        if(this.options != null) {
            this.options.toBundle(arg3);
        }
    }
}

